import 'dart:math';

import 'package:daoyi_ui_admin_getx/app/common/utils/random_contrasting_colors_util.dart';
import 'package:flutter/material.dart';

class CommonTag extends StatelessWidget {
  final String title;
  final Color color;
  final Color textColor;

  const CommonTag(
    this.title, {
    super.key,
    this.color = Colors.grey,
    this.textColor = Colors.black,
  });

  factory CommonTag.factory(String title) {
    List<Color> colors =
        RandomContrastingColorsUtil.generateHighContrastColors();
    return CommonTag(
      title,
      color: colors[0],
      textColor: colors[1],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: color,
        borderRadius: BorderRadius.circular(6),
      ),
      padding: const EdgeInsets.only(
        left: 4,
        right: 4,
        top: 2,
        bottom: 2,
      ),
      margin: const EdgeInsets.only(right: 4),
      child: Text(
        title,
        style: TextStyle(
          color: textColor,
          fontSize: 11,
          fontWeight: FontWeight.w600,
        ),
      ),
    );
  }
}
